package com.seven.commons;

/**
 * @工程名:common-utils
 * @作者: sevenDay
 * @时间: 2019/4/8 21:56
 * @描述:
 */
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;

public class MethodDemo {

    public static void main(String[] args) {
        Method[] methods = SampleClass.class.getMethods();
        Type returnType = methods[0].getGenericReturnType();
        final Type[] actualTypeArguments = ((ParameterizedType) returnType).getActualTypeArguments();
        final Type rawType = ((ParameterizedType) returnType).getRawType();
        System.out.println(returnType);
        //rawType.getTypeName().contains("List")
        //Class.forName("java.lang.String")

    }
}

class SampleClass {
    private ArrayList<String> sampleField;

    public ArrayList<String> getSampleField() {
        return sampleField;
    }

    public void setSampleField(ArrayList<String> sampleField) {
        this.sampleField = sampleField;
    }
}

